package com.base.model;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.base.control.MActivitySupport;
import com.base.control.RequestCallback;

import java.util.List;

public abstract class MAdapter<T> extends BaseAdapter implements RequestCallback {
    protected int nowPosition;
	protected List<T> list;
    protected MActivitySupport mActivitySupport;
	protected LayoutInflater mInflater;
	
	public MAdapter(List<T> list, MActivitySupport context) {
		super();
		this.list = list;
		this.mInflater = LayoutInflater.from(context);
        this.mActivitySupport = context;
	}

    public MActivitySupport getMActivity() {
        return mActivitySupport;
    }

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int index) {
		return list.get(index);
	}

	@Override
	public long getItemId(int index) {
		return index;
	}

	@Override
	public abstract View getView(int position, View convertView, ViewGroup viewGroup);


    //网络请求回调，子类可选
    @Override
    public void onRequestError(Integer errcode, String errmsg) {

    }

    @Override
    public void onRequestSuccess(Bean2Json data) {

    }

    //getter and setter
    public int getNowPosition() {
        return nowPosition;
    }

    public void setNowPosition(int nowPosition) {
        this.nowPosition = nowPosition;
    }


}
